package moodish.comm;

import java.sql.ClientInfoStatus;

import moodish.comm.IClientSideMessage;
import moodish.comm.IServerSideMessage;

/**
 * 
 * @author marta
 * @version 1.0
 * Classe que representa uma mensagem vinda do cliente
 * @see Message
 *
 */
public class MessageFromClient extends Message implements IServerSideMessage {
	
	private String sender;
	private String payload;
	private String receiver;
	private IServerSideMessage.Type type;
	
	/**
	 * 
	 * @param sender nome de quem enviou a mensagem
	 * @param payload conteudo da mensagem
	 * @param receiver destino da mensagem
	 * @param type tipo
	 * @see IServerSideMessage
	 */
	public MessageFromClient(String sender, String payload,String receiver, Type type) {
		super();
		this.sender = sender;
		this.payload = payload;
		this.receiver = receiver;
		this.type = type;
	}
	
	@Override
	public Type getType() {
		return type;
	}
	@Override
	public String getPayload() {
		if(type == Type.MOODISH_MESSAGE|| type == Type.FRIENDSHIP || type == Type.UNFREINDSHIP)
			return payload;
			return null;
	}
	@Override
	public String getClientNickname() {
		return sender;
	}

	@Override
	public String toString() {
		return "MessageFromClient [sender=" + sender + ", payload="
				+ payload + ", receiver=" + receiver + ", type=" + type
				+ "]";
	}
	
	


}
